/**
 * <p>Copyright (c) 2017 深圳市鹏途交通科技有限公司 </p>
 * <p>				   All right reserved. 		     </p>
 * 
 * <p>项目名称 ： 	         </p>
 * <p>创建者   :	win7 
 * 
 * <p>描   述  :   DevelopTargetServiceImpl.java for com.pengtu.gsj.service.impl.jhgl    </p>
 * 
 * <p>最后修改 : $: 2017年6月28日-下午6:18:58 v 1.0.0	 win7   $ </p>
 * 
*/

package com.pengtu.gsj.service.impl.jhgl;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.pengtu.gsj.dao.base.Page;
import com.pengtu.gsj.dao.base.QueryFilter;
import com.pengtu.gsj.dao.jhgl.DevelopTargetDao;
import com.pengtu.gsj.entity.app.Attachment;
import com.pengtu.gsj.entity.jhgl.DevelopTarget;
import com.pengtu.gsj.service.jhgl.DevelopTargetService;
import com.pengtu.gsj.service.system.SystemManageService;

/**
 * 
 * DevelopTargetServiceImpl
 * 
 * 2017年6月28日 下午6:18:58
 * 
 * @version 1.0.0
 * 
 */
@Transactional
@Service
public class DevelopTargetServiceImpl implements DevelopTargetService{
	
	@Autowired
	private DevelopTargetDao developTargetDao;
	
	@Autowired
	private SystemManageService systemManageService;
	
	
	
	@Override
	public void saveDevelopTarget(DevelopTarget developTarget){
		developTargetDao.save(developTarget);
	}
	
	@Override
	public Page<DevelopTarget> findDevelopTarget(Page<DevelopTarget> page, final QueryFilter queryFilter){
		return developTargetDao.findPage(page, queryFilter);
	}
	
	@Override
	public DevelopTarget getDevelopTargetById(String id){
		return developTargetDao.get(id);
	}
	
	@Override
	public void  delateDevelopTarget(DevelopTarget developTarget){
		if(developTarget.getAttachments() != null){
			for(Attachment attachment : developTarget.getAttachments()){
				systemManageService.deleteAttachment(attachment);
			}
		}
		developTargetDao.delete(developTarget);
	}
	
	@Override
	public boolean checkTecYear(String tecYear, String id){
		return developTargetDao.checkProperty("year", tecYear, id);
	}
}
